feat: top-5 improvements — model split, render coalescing, auto-reconnect - #14
Merged
Conversation
model.go had grown to 1268 lines mixing event ingestion, keyboard handling, autocomplete, and approvals. Move whole functions into events.go (client.Event handling, notices, step previews), input.go (completion popup state + key capture, prompt submit), and approval.go (approval key capture + answer). Pure refactor: no behavior change, tests pass unchanged.
token/thinking events used to rebuild the viewport — re-running glamour on the streaming tail — on every single event. They now share one coalesced flush (renderFlushMsg) per streamRenderInterval; done, error, and disconnect still render eagerly and drop any pending flush.
…et drop A dropped WebSocket used to be terminal: one _disconnected event and the TUI settled into a dead state even though the session (id + auth token) survives server-side. Now a drop schedules redials with exponential backoff (500ms-8s, 5 attempts) via a Reconnect hook wired in main. On success the client and event stream are swapped and the next prompt re-binds the session transparently; on exhaustion the previous terminal disconnected state (with the server log hint) is kept. The badge reads "reconnecting…" while retries are in flight.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the actionable items from the top-5 improvement review (see commit list). Deliberately excluded: swapping the WebSocket library (rejected — stays on
golang.org/x/net/websocket) and the cross-repo protocol contract test (deferred; it needs an odek-side fixture to be meaningful).Commits
model.go(627) +events.go+input.go+approval.go; tests driveModeldirectly so nothing breaks.SetContentper token; renders batch into one flush per 80ms tick._disconnected→ dead TUI). odek serve cancels the turn on disconnect but the session (id + auth token) survives, so bodek now redials with exponential backoff (500ms → 8s, 5 attempts) and the next prompt transparently re-binds the session — every prompt already carriessession_id+auth_token. The badge readsreconnecting…during retries; a server that stays down keeps the old terminaldisconnectedstate with the log-path hint.Already on main (from the same review)
fix/skill-notices-auto-dismiss-3s).Checklist
make fmt/make vet/make lint(0 issues) /make test(race) — all greeninternal/tui/reconnect_test.go(schedule/success/retry-exhaustion/stale-result/backoff/badge)